import { createRouter, createWebHistory } from 'vue-router'
// import { useTokenStore } from '@/stores'
const router = createRouter({
 history: createWebHistory(import.meta.env.BASE_URL),
 routes: [
  {
   path: '/login',
   component: () => import('@/views/login/login.vue')
  }, // 登录页
  {
   path: '/manger',
   component: () => import('@/views/Layout/Layout.vue'),
   redirect: '/AllData',
   children: [
    {
     path: '/AllData',
     component: () => import('@/views/AllData/alldata.vue')
    },
    {
     path: '/ActiveList',
     component: () => import('@/views/ActiveList/activeList.vue')
    },
    {
     path: '/ModelList',
     component: () => import('@/views/ModelList/modelList.vue')
    },
    {
     path: '/UserList',
     component: () => import('@/views/UserList/userList.vue')
    }
   ]
  }
 ]
})
// router.beforeEach((to) => {
//   // 如果没有token, 且访问的是非登录页，拦截到登录，其他情况正常放行
//   const tokenStore = useTokenStore()
//   if (!tokenStore.accessToken && to.path !== '/login') return '/login'
//   else return '/manger'
// })

export default router
